/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 不同步的银行例子
 * @Description *
 * @Package concurrent.example.bank
 * @date 2021/3/10 10:26 上午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package concurrent.bank;

public class UnsynchBankTest {

    public static final int INITIAL_BALANCE = 100;
    public static final int ACCOUNT_SUM = 10;
    public static final int TRANSFER_COUNT = 10;

    public static void main(String[] args) {
        Bank b = new Bank(ACCOUNT_SUM, INITIAL_BALANCE);
        //每个账户 都给另一个随机账户 一直转账随机金额   BUG:这里的 随机目标账户有可能转给自己
        System.out.print("===============新一轮转账开始===============\n");
        for (int i = 0; i < TRANSFER_COUNT; i++) {
            TransferRunnable transferRunnable = new TransferRunnable(b, i, INITIAL_BALANCE);
            Thread thread = new Thread(transferRunnable);
            thread.start();
        }
        System.out.print("===============本轮转账结束===============\n");
    }
}
